import { IPSDERAggData } from './ipsderagg-data';
import { IPSDERAggDataDEFieldMap } from './ipsderagg-data-defield-map';
import { PSDERBaseImpl } from './psderbase-impl';
import { IPSDEDataSet } from '../ds/ipsdedata-set';

export class PSDERAggDataImpl extends PSDERBaseImpl implements IPSDERAggData {
  protected psderaggdatadefieldmaps: IPSDERAggDataDEFieldMap[] | null = null;

  getPSDERAggDataDEFieldMaps(): IPSDERAggDataDEFieldMap[] | null {
    if (this.psderaggdatadefieldmaps == null) {
      this.psderaggdatadefieldmaps = this.fillChildListModel(this.M.getPSDERAggDataDEFieldMaps, 'dataentity.der.IPSDERAggDataDEFieldMap') as IPSDERAggDataDEFieldMap[];
    }
    return this.psderaggdatadefieldmaps;
  }

  get psDERAggDataDEFieldMaps(): IPSDERAggDataDEFieldMap[] | null {
    return this.getPSDERAggDataDEFieldMaps();
  }

  findPSDERAggDataDEFieldMap(objKey: any): IPSDERAggDataDEFieldMap | null {
    return this.getPSModel5('dataentity.der.IPSDERAggDataDEFieldMap', this.getPSDERAggDataDEFieldMaps(), objKey) as IPSDERAggDataDEFieldMap;
  }

  protected sourcepsdedataset: IPSDEDataSet | null = null;

  getSourcePSDEDataSet(): IPSDEDataSet | null {
    if (this.sourcepsdedataset != null) return this.sourcepsdedataset;
    const value = this.M.getSourcePSDEDataSet;
    if (value == null) {
      return null;
    }
    this.sourcepsdedataset = this.getMinorPSDataEntityMust().findPSDEDataSet(value);
    return this.sourcepsdedataset;
  }

  get sourcePSDEDataSet(): IPSDEDataSet | null {
    return this.getSourcePSDEDataSet();
  }

  getSourcePSDEDataSetMust(): IPSDEDataSet {
    const value = this.getSourcePSDEDataSet();
    if (value == null) {
      throw new Error('未指定源数据集对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSDERAggDataImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.der.IPSDERAggData') return true;
    return super.instanceof(cls);
  }
}
